<script type="text/javascript">	
	var department_select = "<?=$department_select;?>";
</script>

<h2><?=$mycompany->company_name;?></h2>

<div class="block tabs spaces">
	<div class="hd">
		<ul>
			<li><a href="<?=site_url('yourcompany');?>">Departments</a></li>
			<li><a>People</a></li>
		</ul>
		<div class="clear"></div>
	</div>
		<div class="bd">

		<?php if($departments):?>
			<?php foreach($departments as $department):?>
			<h2><?=$department->centertitle;?></h2>
		
			<?php if($department->users):?>
				
			<table>
				<thead>
					<td>Name</td>
					<td>Type</td>
					<td>&nbsp;</td>
				</thead>
				
				<tbody>
					<?php foreach ($department->users as $key => $user):?>
					<tr>
						<td><a href="<?=site_url('users/modify/'.$user->id);?>"><?=( $user->firstname || $user->lastname ? $user->firstname.' '.$user->lastname : $user->emailaddress);?></a></td>
						<td>
							<?php if ($user->profiletype == 'admin'):?>Admin<?php endif;?>
							<?php if ($user->profiletype == 'standard'):?>Standard<?php endif;?>
						</td>
						<td>
							<a href="<?=site_url('users/view/'.$user->id);?>" class="">See Stats</a>
							<a href="<?=site_url('users/delete/'.$user->id);?>" class="">Send Password</a>
					
							<?php if ($user->active):?>
							<a class="" href="<?=site_url('users/deactivate/'.$user->id);?>">Deactivate</a><?php else: ?>
							<a class="" href="<?=site_url('users/activate/'.$user->id);?>">Activate</a>
							<?php endif;?>
						
							<a href="<?=site_url('users/delete/'.$user->id);?>" class="">Delete</a>
						</td>
					</tr>
					<?php endforeach; ?>
				</tbody>
			</table>

			<?php else: ?>
			<p>No users in this department.</p>
			<?php endif;?>
		
			<?php endforeach; ?>
			
		<?php endif;?>

</div></div></div></div></div>

<div id="sidebar" class="yui-b">
		<div class="block">
			<div class="hd">
				<h2>Add a new user</h2>
			</div>
			<div class="bd">
					<?=form_open('users/add', array('class' => ''));?>

						<fieldset>
							<p>
								<label for="emailaddress" class="required">Email address</label>
								<input class="text" type="text" name="emailaddress" id="emailaddress" value="" />
							</p>

							<p>
								<label for="password" >Password</label>
								<input class="text" type="password" name="password" id="password"  />
							</p>

							<p>
								<label for="confirm-password">Confirm Password</label>
								<input class="text" type="password" name="confirm-password" id="confirm-password" />
							</p>
						</fieldset>

						<fieldset>
							<p>
								<label for="firstname" class="required">Firstname</label>
								<input class="text" type="text" name="firstname" id="firstname" value="" />
							</p>

							<p>
								<label for="lastname" class="required">Surname</label>
								<input class="text" type="text" name="lastname" id="lastname" value="" />
							</p>
						</fieldset>

						<fieldset>
							<p>
								<label for="active" class="required">Active</label>
								<select class="text" name="active" id="active">
									<option value="1" selected="selected">Yes</option>
									<option value="0">No</option>
								</select>
							</p>

							<p>
								<label for="costcenterid">Department</label>
								<select class="text" name="costcenterid">
									<?php foreach($departments as $department):?>
									<option value="<?=$department->id;?>"><?=$department->centertitle;?></option>
									<?php endforeach;?>
								</select>
							</p>

							<p>
								<label for="autoassign" class="required">Auto Assign to projects for their department?</label>
								<select class="text" name="autoassign" id="autoassign">
									<option value="1" selected="selected">Yes</option>
									<option value="0">No</option>
								</select>
							</p>

						</fieldset>

						<input type="submit" name="Submit" value="Save" class="">

				<?=form_close();?>
			</div>
		</div>
</div>